// iPad 和响应式适配样式
// 设备断点定义
$mobile-max: 767px;
$tablet-min: 768px;
$tablet-max: 1024px;
$desktop-min: 1025px;

// iPad 专用断点
$ipad-portrait: 768px;
$ipad-landscape: 1024px;
$ipad-pro-portrait: 834px;
$ipad-pro-landscape: 1194px;

// 基础响应式混合器
@mixin mobile-only {
  @media (max-width: $mobile-max) {
    @content;
  }
}

@mixin tablet-only {
  @media (min-width: $tablet-min) and (max-width: $tablet-max) {
    @content;
  }
}

@mixin desktop-only {
  @media (min-width: $desktop-min) {
    @content;
  }
}

// iPad 专用混合器
@mixin ipad-portrait {
  @media (min-width: $ipad-portrait) and (max-width: $ipad-portrait) and (orientation: portrait) {
    @content;
  }
}

@mixin ipad-landscape {
  @media (min-width: $ipad-landscape) and (max-width: $ipad-landscape) and (orientation: landscape) {
    @content;
  }
}

@mixin ipad-pro-portrait {
  @media (min-width: $ipad-pro-portrait) and (max-width: $ipad-pro-portrait) and (orientation: portrait) {
    @content;
  }
}

@mixin ipad-pro-landscape {
  @media (min-width: $ipad-pro-landscape) and (max-width: $ipad-pro-landscape) and (orientation: landscape) {
    @content;
  }
}

// 通用iPad适配
@mixin ipad-all {
  @media (min-width: $tablet-min) and (max-width: $ipad-pro-landscape) {
    @content;
  }
}

// 全局响应式基础样式
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  
  @include tablet-only {
    font-size: 18px;
  }
  
  @include mobile-only {
    font-size: 14px;
  }
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  
  @include ipad-all {
    // iPad 专用字体优化
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

// 容器响应式
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  
  @include tablet-only {
    padding: 0 24px;
  }
  
  @include desktop-only {
    padding: 0 32px;
  }
}

// 布局组件响应式
.layout-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  
  @include tablet-only {
    flex-direction: row;
  }
}

// 侧边栏响应式
.sidebar {
  width: 100%;
  
  @include tablet-only {
    width: 280px;
    min-width: 280px;
  }
  
  @include ipad-landscape {
    width: 320px;
    min-width: 320px;
  }
  
  @include desktop-only {
    width: 300px;
    min-width: 300px;
  }
}

// 主内容区响应式
.main-content {
  flex: 1;
  padding: 0;
  margin: 0;

  @include tablet-only {
    padding: 0;
    margin: 0;
  }

  @include desktop-only {
    padding: 0;
    margin: 0;
  }
}

// 表格响应式
.responsive-table {
  width: 100%;
  overflow-x: auto;
  
  table {
    width: 100%;
    min-width: 600px;
    
    @include tablet-only {
      min-width: 800px;
    }
    
    @include desktop-only {
      min-width: 1000px;
    }
  }
  
  th, td {
    padding: 8px 12px;
    
    @include tablet-only {
      padding: 12px 16px;
    }
    
    @include desktop-only {
      padding: 16px 20px;
    }
  }
}

// 按钮响应式
.btn {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  
  @include tablet-only {
    padding: 12px 24px;
    font-size: 16px;
  }
  
  @include ipad-all {
    // iPad 触摸优化
    min-height: 44px;
    min-width: 44px;
  }
}

// 表单元素响应式
.form-item {
  margin-bottom: 16px;
  
  @include tablet-only {
    margin-bottom: 20px;
  }
  
  label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    
    @include tablet-only {
      margin-bottom: 8px;
    }
  }
  
  input, select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    
    @include tablet-only {
      padding: 12px 16px;
      font-size: 16px;
    }
    
    @include ipad-all {
      // iPad 输入优化
      min-height: 44px;
    }
  }
}

// 卡片组件响应式
.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 16px;
  margin-bottom: 16px;
  
  @include tablet-only {
    padding: 24px;
    margin-bottom: 24px;
    border-radius: 12px;
  }
  
  @include desktop-only {
    padding: 32px;
    margin-bottom: 32px;
  }
}

// 网格系统响应式
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  
  @include tablet-only {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }
  
  @include desktop-only {
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
  }
  
  &.grid-2 {
    @include tablet-only {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  
  &.grid-4 {
    @include desktop-only {
      grid-template-columns: repeat(4, 1fr);
    }
  }
}

// 文字响应式
.text-responsive {
  font-size: 14px;
  
  @include tablet-only {
    font-size: 16px;
  }
  
  @include desktop-only {
    font-size: 18px;
  }
}

// 标题响应式
.title {
  &.h1 {
    font-size: 24px;
    
    @include tablet-only {
      font-size: 32px;
    }
    
    @include desktop-only {
      font-size: 36px;
    }
  }
  
  &.h2 {
    font-size: 20px;
    
    @include tablet-only {
      font-size: 24px;
    }
    
    @include desktop-only {
      font-size: 28px;
    }
  }
  
  &.h3 {
    font-size: 18px;
    
    @include tablet-only {
      font-size: 20px;
    }
    
    @include desktop-only {
      font-size: 24px;
    }
  }
}

// iPad 专用优化
@include ipad-all {
  // 触摸优化
  .clickable {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }
  
  // 滚动优化
  .scrollable {
    -webkit-overflow-scrolling: touch;
  }
  
  // 输入优化
  input, textarea, select {
    -webkit-appearance: none;
    border-radius: 8px;
  }
  
  // 按钮优化
  button {
    -webkit-appearance: none;
    border-radius: 8px;
  }
}

// 隐藏/显示工具类
.hide-mobile {
  @include mobile-only {
    display: none !important;
  }
}

.hide-tablet {
  @include tablet-only {
    display: none !important;
  }
}

.hide-desktop {
  @include desktop-only {
    display: none !important;
  }
}

.show-mobile {
  display: none !important;
  
  @include mobile-only {
    display: block !important;
  }
}

.show-tablet {
  display: none !important;
  
  @include tablet-only {
    display: block !important;
  }
}

.show-desktop {
  display: none !important;
  
  @include desktop-only {
    display: block !important;
  }
}
